home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / program / tcqbsnip.zip / PASSREF.BAS < prev    next >
BASIC Source File  |  1997-06-20  |  1KB  |  57 lines

  1. ' PASSREF.BAS
  2. ' by Tika Carr
  3. ' March 1997
  4. '
  5. ' Donated to the public domain
  6. ' No warranties or guarantees are expressed or implied.
  7. '
  8. ' Purpose: Demo of pass by reference and getting around global variables
  9.  
  10. DECLARE SUB Decrement (i%)
  11. DECLARE SUB Increment (i%)
  12.  
  13. CLS
  14.  
  15. a% = 1
  16.  
  17. ' results 1 1 2
  18. PRINT "Round 1:"
  19. PRINT "Initial Value:"; a%
  20. Increment (a%)
  21. PRINT "Passed by reference: "; a%
  22. Increment a%
  23. PRINT "Passed by value: "; a%
  24. PRINT
  25.  
  26. 'results 2 3 2 3
  27. PRINT "Round 2: Pass by reference"
  28. a% = 2
  29. PRINT "Initial Value:"; a%
  30. Increment a%
  31. PRINT "After Increment:"; a%
  32. Decrement a%
  33. PRINT "After Decrement:"; a%
  34. Increment a%
  35. PRINT "After Second Increment:"; a%
  36. PRINT
  37.  
  38. 'results 3 3 3 3
  39. PRINT "Round 3: Pass by value"
  40. PRINT "Initial Value"; a%
  41. Increment (a%)
  42. PRINT "After Increment:"; a%
  43. Decrement (a%)
  44. PRINT "After Decrement:"; a%
  45. Increment (a%)
  46. PRINT "After Second Increment:"; a%
  47. END
  48.  
  49. SUB Decrement (i%) STATIC
  50.   i% = i% - 1
  51. END SUB
  52.  
  53. SUB Increment (i%) STATIC
  54.   i% = i% + 1
  55. END SUB
  56.  
  57.